import datetime
import time
""" 时间戳转换为时间

'LotteryTime': '1699785000'
"""


def timestamp2Date(timestamp):
    # 使用datetime.fromtimestamp()方法将时间戳转换为datetime对象
    dt_object = datetime.datetime.fromtimestamp(timestamp)
    # 使用strftime()方法将datetime对象格式化为字符串
    formatted_time = dt_object.strftime('%Y-%m-%d %H:%M:%S')
    return formatted_time


def getDate():
    now = datetime.datetime.now()
    return now.strftime('%Y-%m-%d %H:%M:%S')

"""
 获取小时
"""
def getHour():
    now = datetime.datetime.now()
    return now.strftime('%H')

"""
 获取日期
"""
def getDay():
    now = datetime.datetime.now()
    return now.strftime('%Y-%m-%d')


def getSecondDistince(Interval):
    timestamp = time.time()
    formatted_timestamp = str(timestamp)[:10]
    return Interval - int(formatted_timestamp) % Interval

def getSecondDistince12Hour():
    timestamp = time.time()
    formatted_timestamp = str(timestamp)[:10]
    return 1*60*60*15 - int(formatted_timestamp) % (1*60*60*15)
if __name__ == "__main__":
    for i in range(1000):
        print(getSecondDistince(90))
        print(getSecondDistince(1*60*60*24*3))
        time.sleep(1)
